package com.xiliubit.cloudpicture.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

@Configuration
public class DeletePictureThreadPoolConfig {

    /**
     * 创建一个删除图片的异步线程池任务执行器
     */
    @Bean("asyncDeletePictureExecutor")
    public Executor asyncDeletePictureExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.setMaxPoolSize(10);
        executor.setQueueCapacity(25);
        executor.setThreadNamePrefix("delete-picture - ");
        executor.initialize();
        return executor;
    }
}
